/*
 * Path.cpp
 *
 *  Created on: Jan 19, 2012
 *      Author: jacobimo
 */

#include "Path.h"

//ctor
Path::Path(int lenght) {
	this->_lenght=lenght;
	this->_location=new Location[lenght];
	this->_count=0;

}

//copy ctor
Path::Path(const Path &p)
{
	this->_lenght=p._lenght;
	this->_location=new Location[p._lenght];
	_count = p._count;
	for (int i =0; i<p.getLenght();i++)
	{
		this->_location[i]=p._location[i];
	}

}

//dtor
Path::~Path() {
	delete[] this->_location;
}

//add new location to the path
int Path::add(const Location& loc)
{
	if (_count<_lenght) {

		_location[_count]= loc;
	}
	return _count++;
}

//add new location with x and y
int Path::add(int x, int y)
{
	if (_count<_lenght) {
		this->_location[_count].setX(x);
		this->_location[_count].setY(y);
	}
	return _count++;
}

//get the amount of location the been enter to the path
int Path::getCount() const
{
	return _count;
}

//get the lenght of the max size of the path
int Path::getLenght() const
{
	return _lenght;
}
